package com.example.storagemodule

import android.content.Context
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.core.content.edit
import com.example.storagemodule.utils.open
import kotlinx.android.synthetic.main.activity_sp.*

/**
 * Sp存储的界面
 */
class SpActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_sp)




    }

    fun save(view: View) {
        //得到SP对象
        //得到Editor对象
        val sp = getSharedPreferences("zy", MODE_PRIVATE)

        //得到输入的key-value
        sp.edit {
            run {  }

        }
        sp.open {
            //使用editor保存key-value
            putInt(et_sp_key.text.toString(),et_sp_value.text.toString().toInt())
        }


        Toast.makeText(this,"保存完成",Toast.LENGTH_SHORT).show()
    }
    fun read(view: View) {

    }
}